package com.cqc.transition01;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.SimpleAdapter;
import android.widget.StackView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ${cqc} on 2017/7/21.
 * StackView：浏览图片，同listView一样，需要设置adapter
 */

public class StackViewActivity extends AppCompatActivity {

    private Context context = this;
    private StackView stackView;
    private int[] imgArray = {R.mipmap.a,R.mipmap.b,R.mipmap.c,R.mipmap.d,R.mipmap.e,R.mipmap.f};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activivity_stack_view);

        stackView = (StackView) findViewById(R.id.stackView);

        List<Map<String ,Object>> list = new ArrayList<>();
        for (int i = 0; i < imgArray.length; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("image",imgArray[i]);
            list.add(map);
        }
        SimpleAdapter adapter = new SimpleAdapter(context,list,R.layout.item_1,new String[]{"image"},new int[]{R.id.iv});
        stackView.setAdapter(adapter);

    }
}
